# Maintainer: Jefferson Gonzalez <jgmdev@gmail.com>

pkgname=dkms-8812au
_pkgbase=8812au
_commit=40eafac156c1ce5e736f9767b27dd967a4ae5cbe
pkgver=4.2.2.g${_commit:0:7}
pkgrel=1
pkgdesc="Driver for Realtek RTL8812AU chipset wireless adaptors."
arch=('arm' 'armv6h' 'armv7h' 'aarch64')
url="http://www.realtek.com.tw/"
license=('GPL')
depends=('dkms' 'linux-headers')
conflicts=()
options=(!strip)
source=(
  "https://github.com/gnab/rtl8812au/archive/${_commit}.zip"
  'dkms.conf'
  'rtl8812au.conf'
)
md5sums=(
  '19f23c615a12f9038d49a5aacfffbf6e'
  '1d9e2b78b4a2bdd48ea360550ed0aea7'
  '6744a04569752913032ef033e1475376'
)

package() {
  cd ${srcdir}/rtl8812au-$_commit

  install -d ${pkgdir}/etc/modprobe.d
  install -d ${pkgdir}/usr/src/${_pkgbase}-${pkgver}

  cp -pr * ${pkgdir}/usr/src/${_pkgbase}-${pkgver}/
  cp ${srcdir}/dkms.conf ${pkgdir}/usr/src/${_pkgbase}-${pkgver}/
  cp ${srcdir}/rtl8812au.conf ${pkgdir}/etc/modprobe.d/

  _arch="arm"
  case "${CARCH}" in
    aarch64|arm64)
      _arch="arm64"
      ;;
    *)
  esac

  # Set name and version
  sed -e "s/@PKGBASE@/${_pkgbase}/" \
    -e "s/@PKGVER@/${pkgver}/" \
    -e "s/@ARCH@/${_arch}/" \
    -i "${pkgdir}"/usr/src/${_pkgbase}-${pkgver}/dkms.conf
}